/*
 
 Copyright (c) 2010 Xiotex Studios Ltd.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The end-user documentation included with the redistribution, if any, must
 include the following acknowledgment: "This product includes software
 developed by Xiotex Studios Ltd (http://xiotexstudios.com)", in the same
 place and form as other third-party acknowledgments. Alternately, this
 acknowledgment may appear in the software itself, in the same form and
 location as other such third-party acknowledgments.
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. 
 
 */

#ifndef __SWFTYPES_H__
#define __SWFTYPES_H__

#include <vector>
#include <string>

#define SWF_DUMP

typedef unsigned char* swf_stream;
typedef unsigned long DWORD;

class CSWFPlayHead;
class CSWFTagList;

typedef struct _tagTagShort
{
	DWORD	m_dwTagID;
	DWORD	m_dwLength;
	
} SWF_TAG_SHORT, *PSWF_TAG_SHORT;

typedef struct _tagTagLong
{
	DWORD	m_dwTagID;
	DWORD	m_dwLength16;
	DWORD	m_dwLength;
	
} SWF_TAG_LONG, *PSWF_TAG_LONG;

typedef enum HeaderLengths
{
	SWF_SHORT_TAG_HEADER_LENGTH = 2,
	SWF_LONG_TAG_HEADER_LENGTH = 6,
	
} SWF_TAG_HEADER_LENGTHS;


typedef struct _tagSWFRGB
{
	unsigned char	m_R;
	unsigned char	m_G;
	unsigned char	m_B;
	
} SWF_RGB, *PSWF_RGB;

typedef struct _tagSWFRGBA
{
	unsigned char	m_R;
	unsigned char	m_G;
	unsigned char	m_B;
	unsigned char	m_A;
	
} SWF_RGBA, *PSWF_RGBA;

typedef struct _tagSWFRECT
{
	long	m_dwXMin;
	long	m_dwYMin;
	long	m_dwXMax;
	long	m_dwYMax;
	
} SWF_RECT, *PSWF_RECT;

typedef struct _tagSWFMatrixRecord
{
	float	m_fScaleX;
	float	m_fScaleY;
	float	m_fRotateSkew1;
	float	m_fRotateSkew0;
	float	m_fTranslateX;
	float	m_fTranslateY;
	
} SWF_MATRIX_RECORD, *PSWF_MATRIX_RECORD;

typedef struct _tagSWFColourTransform
{
	long		m_lRAdd;
	long		m_lGAdd;
	long		m_lBAdd;
	long		m_lAAdd;
	long		m_lRMult;
	long		m_lGMult;
	long		m_lBMult;
	long		m_lAMult;
	
	
} SWF_COLOUR_TRANSFORM, *PSWF_COLOUR_TRANSFORM;

typedef enum SWFOffsetSkips
{
	SWF_SKIP_BYTE		= 1,
	SWF_SKIP_WORD		= 2,
	
} SWF_SKIP_OFFSETS;

typedef enum SWFTwips
{
	SWF_TWIPS			= 20,
	
} SWF_TWIPS_VALUE;

typedef enum SWFMaxValues
{
	SWF_MAX_BYTE		= 0xff,
	
} SWF_MAX_VALUES;

typedef enum SWFEdgeTypeFlags
{
	SWF_NO_EDGE			= 0,
	SWF_EDGE			= 1,
	
} SWF_EDGE_FLAGS;

typedef enum SWFFillTypeValues
{
	SWF_SOLID_FILL					= 0x00,
	SWF_LINEAR_GRADIENT				= 0x10,
	SWF_RADIAL_GRADIENT				= 0x12,
	SWF_REPEATING_BITMAP			= 0x40,
	SWF_CLIPPED_BITMAP				= 0x41,
	SWF_NON_SMOOTHED_BITMAP			= 0x42,
	SWF_NON_SMOOTHED_CLIPPED_BITMAP	= 0x43,
	
} SWF_FILL_TYPE_VALUES;

typedef enum SWFShapeType
{
	SWF_SHAPE1	= 0,
	SWF_SHAPE2	= 1,
	SWF_SHAPE3	= 2,
	
} SWF_SHAPE_TYPE;


typedef enum SWFHeader
{
	SWF_F				= 0,
	SWF_W				= 1,
	SWF_S				= 2,
	SWF_FLASH_VERSION	= 3,
	SWF_FILE_SIZE		= 4,
	SWF_FRAME_SIZE		= 8,
	SWF_FRAME_RATE		= 17,
	SWF_FRAME_COUNT		= 19,
	SWF_START_OF_MOVIE	= 21,
	
} SWF_FILE_HEADER_BYTE_POSITIONS;

typedef enum SWF_TagNames
{
	SWF_END						= 0,
	SWF_SHOW_FRAME				= 1,
	SWF_DEFINE_SHAPE			= 2,
	SWF_PLACE_OBJECT			= 4,
	SWF_REMOVE_OBJECT			= 5,
	SWF_SET_BACKGROUND_COLOR	= 9,
	SWF_DEFINE_SHAPE_2			= 22,
	SWF_PROTECT					= 24,
	SWF_PLACE_OBJECT_2			= 26,
	SWF_REMOVE_OBJECT_2			= 28,
	SWF_DEFINE_SHAPE_3			= 32,
	SWF_DEFINE_SPRITE			= 39,
	SWF_FRAME_LABEL				= 43,
	SWF_EXPORT_ASSETS			= 56,
	SWF_IMPORT_ASSETS			= 57,
	SWF_ENABLE_DEBUGGER			= 58,
	SWF_ENABLE_DEBUGGER_2		= 64,
	SWF_SCRIPT_LIMITS			= 65,
	SWF_SET_TAB_LIMITS			= 66,
	
} SWF_TAG_NAMES;

typedef enum SWF_HeaderSizes
{
	SWF_RECT_HEADER_SIZE	= 5,
	
} SWF_HEADER_SIZES;

typedef struct _tagTag
{
	DWORD					m_dwType;
	DWORD					m_dwLength;
	swf_stream				m_pStream;
	DWORD					m_dwID;
	
	bool					m_bHasClipActions;
	bool					m_bHasClipDepth;
	bool					m_bHasName;
	bool					m_bHasColourTransform;
	bool					m_bHasMatrix;
	bool					m_bHasCharacter;
	bool					m_bHasMove;
	bool					m_bHasRatio;
	SWF_MATRIX_RECORD		m_mMatrix;
	DWORD					m_dwCharacterID;
	SWF_COLOUR_TRANSFORM	m_ColourTransform;
	std::string				m_strName;
	DWORD					m_dwClipDepth;
	DWORD					m_dwRatio;
	int						m_iDepth;
	SWF_RECT				m_sRect;
	
	float					m_fScaleX;
	float					m_fScaleY;
	float					m_fTX;
	float					m_fTY;
	float					m_fAngle;
	
	float					m_fParentScaleX;
	float					m_fParentScaleY;
	float					m_fParentAngle;
	float					m_fParentTX;
	float					m_fParentTY;
	bool					m_bSetParent;
	
	float					m_fWidth;
	float					m_fHeight;
	
} SWF_TAG, *PSWF_TAG;


#endif

